﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace CMS.Web.Filters
{
    /// <summary>
    /// 管理员身份验证
    /// </summary>
    public class AdminAuthorizeAttribute : AuthorizeAttribute
    {
        protected override bool AuthorizeCore(HttpContextBase httpContext)
        {
            if (httpContext.Session["AdminID"] == null)
            {
                return false;
            }
            else
            {
                return true;
            }
        }
        /// <summary>
        /// 重写未授权的http请求
        /// </summary>
        /// <param name="filterContext"></param>
        protected override void HandleUnauthorizedRequest(AuthorizationContext filterContext)
        {

            
            
            filterContext.Result = new RedirectResult("~/Admin/Admin/Login");
        }
    }
}